<html>
    <body onload="init()">
        <script type="text/javascript" src="ayuta.lang.js">
        </script>
        <script type="text/javascript" src="ayuta.aop.js">
        </script>
        <script type="text/javascript">
            function init(){
				var Person = new ayuta.Class({
					properties: [
						{name: "name"},
						{name: "age"}
					],
					hello: function() {
						alert("Hello, my name is " + this.getName() + ". " + this.getAge() + " years old.");
					}
				});
				var shiraishi = new Person();
				shiraishi = alex.aop.proxy(shiraishi, function(fn, args, instance, p) {
					console.log("before " + p);
					var result = fn.apply(instance, args);
					console.log("after " + p);
					return result;
				});
				shiraishi = alex.aop.proxy(shiraishi, function(fn, args, instance, p) {
					alert("Before hello!");
					var result = fn.apply(instance, args);
					alert("After hello!");
					return result;
				}, "hello");
				shiraishi = alex.aop.proxy(shiraishi, function(fn, args, instance, p) {
					var propertyName = p.substring(3);
					propertyName = propertyName.charAt(0).toLowerCase() + propertyName.substring(1);
					var getter = alex.beans.getGetter(instance, propertyName);
					console.log("property changed. old value:[" + getter.call(instance) + "] new value:[" + args[0] + "]");
					fn.apply(instance, args);
				}, /^set.*$/);
				shiraishi.setName("逋ｽ遏ｳ");
				shiraishi.setAge(30);
				shiraishi.hello();
            }
        </script>
    </body>
</html>
